package com.haircut.controller;

import cn.hutool.core.bean.BeanUtil;
import com.haircut.base.Result;
import com.haircut.mapper.HaircutConsumptionItem;
import com.haircut.model.dto.ConsumptionItemDTO;
import com.haircut.service.HaircutConsumptionItemService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v1/item")
@RequiredArgsConstructor
@Slf4j
@Tag(name = "理发项目")
public class HairCutItemController {

    private final HaircutConsumptionItemService itemService;

    @Operation(summary = "理发项目")
    @GetMapping("/list")
    public Result<List<ConsumptionItemDTO>> list() {
        List<HaircutConsumptionItem> list = itemService.list();
        List<ConsumptionItemDTO> consumptionItemDTOS = BeanUtil.copyToList(list, ConsumptionItemDTO.class);
        return Result.success(consumptionItemDTOS);
    }
}